package cn.tedu.egnotice1014.controller;


import cn.tedu.egnotice1014.base.response.JsonResult;
import cn.tedu.egnotice1014.mapper.NoticeMapper;
import cn.tedu.egnotice1014.pojo.dto.NoticeAddParam;
import cn.tedu.egnotice1014.pojo.entity.Notice;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@Slf4j
@RestController
@RequestMapping("v1/notice/")
public class NoticeController {
    @Autowired
    private NoticeMapper noticeMapper;

    @PostMapping("add")
    public JsonResult NoticeAdd(NoticeAddParam noticeAddParam){
        log.debug("noticeAddParam="+noticeAddParam);
        Notice notice=new Notice();
        BeanUtils.copyProperties(noticeAddParam,notice);
        notice.setUpdateTime(new Date());
        notice.setUserId(1);
        notice.setCreateTime(new Date());
        log.debug("notice="+notice);
        noticeMapper.addById(notice);
        return JsonResult.ok();
    }


}
